package com.lvhengchang.controller;

import com.lvhengchang.domain.User;
import com.lvhengchang.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class UserController {
    private static final Logger logger = LoggerFactory.getLogger(UserController.class);
    
    @Autowired
    private UserService userService;

    @GetMapping("/user/{userId}")
    public User getUser(@PathVariable("userId") String userId) {
        logger.info("Receiving request for user with ID: {}", userId);
        User user = userService.selectUserByExchangeId(userId);
        logger.info("Found user: {}", user);
        return user;
    }
}
